package com.ruicar.afs.cloud.afscase.processor.util;

import com.ruicar.afs.cloud.afscase.processor.enums.WorkflowType;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;

/**
 * @Description 流程类型获取
 * @Author Peng_Jinbo
 * @Date 2020/07/16 10:27
 */
@UtilityClass
@Slf4j
public class WorkflowTypeUtil {

    /**
     * @Description 根据内部映射key获取流程类型
     * @Author Peng_Jinbo
     * @Date 2020/7/17 14:15
     */
    public WorkflowType getType(String afsFlowKey) {
        WorkflowType rtType = null;
        for (WorkflowType type : WorkflowType.values()) {
            if (type.getAfsFlowKey().equals(afsFlowKey)) {
                rtType = type;
            }
        }
        return rtType;
    }

    /**
     * @Description 根据内部映射key获取审批流程类型code
     * @Author Peng_Jinbo
     * @Date 2020/7/17 14:15
     */
    public String getApproveTypeCode(String afsFlowKey) {
        WorkflowType type = getType(afsFlowKey);
        return Objects.nonNull(type) ? type.getApproveType().getCode() : "";
    }

    /**
     * @Description 根据内部映射key获取审批流程类型描述
     * @Author Peng_Jinbo
     * @Date 2020/7/17 14:15
     */
    public String getApproveTypeName(String afsFlowKey) {
        WorkflowType type = getType(afsFlowKey);
        return Objects.nonNull(type) ? type.getApproveType().getDesc() : "";
    }

}
